Testing equality or nullness with PHPUnit’s assertTrue()
or assertFalse()
should be simplified to the corresponding
dedicated assertion.
Noncompliant code example
assertTrue($a === $b);
assertTrue($a == $b);
assertTrue($a === null);
assertTrue($a !== null);
assertTrue($a !== $b);
assertTrue($a != $b);
assertFalse($a === $b);
assertFalse($a == $b);
assertTrue($a == true);
assertTrue($a == false);
Compliant solution
assertEquals($a, $b);
assertSame($a, $b);
assertNull($a);
assertNotNull($a);
assertNotEquals($a, $b);
assertNotSame($a, $b);
assertNotEquals($a, $b);
assertNotSame($a, $b);
assertTrue($a);
assertFalse($a);